package com.zk.yygh.hosp.utils;

import com.zk.yygh.hosp.helper.JwtHelper;

import javax.servlet.http.HttpServletRequest;

/**
 * 用户认证工具类
 *
 * @author: 张凯
 * @date: 2022/6/17 - 10:15
 */
public class AuthContextHolder {

    //获取用户Id
    public static Long getUserId(HttpServletRequest request){
        //通过header获取token值
        String token = request.getHeader("token");
        Long userId = JwtHelper.getUserId(token);
        return userId;
    }
    //获取用户name
    public static String getUserName(HttpServletRequest request){
        String token = request.getHeader("token");
        String userName = JwtHelper.getUserName(token);
        return userName;
    }
}
